// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import "babel-polyfill";
import Vue from "vue";
import FastClick from "fastclick";
import VueRouter from "vue-router";
import App from "./App";
import routes from "./router";
import "./assets/base.less";

import {
    Tag,
    NavBar,
    Loading,
    Button,
    Row,
    Col,
    Cell,
    NumberKeyboard,
    MyLoding,
    Switch,
    Step,
    StepItem,
    Rate,
    countUp,
    Mask,
    Popup,
    Rollnotice,
    NoticeItem,
    DateTime,
    Badge,
    KeyBoard,
    Calendar,
    Recursive,
    TreeMenu
} from "./components/index";
// import keyboard from './components/passwordKeyBoard'

Vue.component("my-tag", Tag);
Vue.component("my-nav-bar", NavBar);
Vue.component("my-loading", Loading);
Vue.component("my-button", Button);
Vue.component("my-row", Row);
Vue.component("my-col", Col);
Vue.component("my-cell", Cell);
Vue.component("MyNumberKeyboard", NumberKeyboard);
Vue.component("my-loading", MyLoding);
Vue.component("my-switch", Switch);
Vue.component("my-step", Step);
Vue.component("step-item", StepItem);
Vue.component("my-rate", Rate);
Vue.component("my-count", countUp);
Vue.component("my-mask", Mask);
Vue.component("my-popup", Popup);
Vue.component("my-rollnotice", Rollnotice);
Vue.component("rollnotice-item", NoticeItem);
Vue.component("date-time", DateTime);
Vue.component("my-badge", Badge);
Vue.component("pass-keyboard", KeyBoard);
Vue.component("Calendar", Calendar);
Vue.component("Recursive", Recursive);
Vue.component("TreeMenu", TreeMenu);

Vue.use(VueRouter);

const router = new VueRouter({
    routes
});

// 快速点击
FastClick.attach(document.body);

// 为了能够正确执行转场动画，跳转页面的方法需要做一层包装
VueRouter.prototype.$go = function(noAnimate) {
    this.noAnimate = noAnimate || false;
    this.goTo = false;
    this.go(-1);
};
VueRouter.prototype.$push = function(location, noAnimate, onComplete, onAbort) {
    this.noAnimate = noAnimate || false;
    this.goTo = true;
    this.push(location, onComplete, onAbort);
};
VueRouter.prototype.$replace = function(
    location,
    noAnimate,
    onComplete,
    onAbort
) {
    this.noAnimate = noAnimate || false;
    this.goTo = true;
    this.replace(location, onComplete, onAbort);
};

new Vue({
    router,
    render: h => h(App)
}).$mount("#app");
